package com.example.demo.web.common.config;

import org.noear.redisx.RedisClient;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;
import org.noear.solon.cache.jedis.RedisCacheService;
import org.noear.solon.cache.jedis.RedisClientSupplier;
import org.noear.solon.data.cache.CacheService;

/**
 * @author airhead
 */
@Configuration
public class RedisConfig {
  @Bean(typed = true)
  public CacheService defaultCache(@Inject RedisClient redisClient) {
    RedisCacheService cacheService = new RedisCacheService(redisClient, 60 * 60);
    cacheService.enableMd5key(false);
    return cacheService;
  }

  @Bean(typed = true)
  public RedisClient defaultClient(
      @Inject("${demo.redis}") RedisClientSupplier redisClientSupplier) {
    return redisClientSupplier.get();
  }
}
